package com.qqt.csr.route.dto.resp;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.qqt.csr.route.entity.RouteTask;
import com.qqt.csr.route.enums.RouteTaskStatusEnum;
import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class RouteTaskDTO implements Serializable {
    @Serial
    private static final long serialVersionUID = 8592239400215731645L;

    /**
     * 路由id
     */
    private Integer routeId;

    /**
     * 路由任务id
     */
    private String routeTaskId;

    /**
     * 租户id
     */
    private String tenantId;

    /**
     * 渠道id
     */
    private String channelId;

    /**
     * 渠道用户id
     */
    private String channelUserId;

    /**
     * 会话id
     */
    private String conversationId;

    /**
     * 路由任务状态
     */
    private RouteTaskStatusEnum status;

    public static RouteTaskDTO of(RouteTask routeTask) {
        return RouteTaskDTO.builder()
                .routeId(routeTask.getRouteRule().getId())
                .routeTaskId(routeTask.getId())
                .tenantId(routeTask.getTenantId())
                .channelId(routeTask.getChannelId())
                .channelUserId(routeTask.getChannelUserId())
                .conversationId(routeTask.getConversationId())
                .status(routeTask.getStatus())
                .build();
    }
}
